package com.lw.sbdemo2.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.lw.sbdemo2.common.base.BaseEntity;
import com.lw.sbdemo2.common.constant.TkConstants;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.ibatis.type.Alias;

import java.math.BigDecimal;
import java.util.Date;

/**
 * <p>标题: 订单记录表实体</p>
 * <p>描述: </p>
 * <p>版权: Copyright (c) 2019</p>
 * <p>公司: 山人行工作室</p>
 *
 * @version: 1.0
 * @author: LinWang
 * @date 2019-4-14
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Alias("TkOrderRecord")
@ApiModel(description = "订单记录表实体")
public class TkOrderRecord extends BaseEntity {

    @ApiModelProperty(value = "订单ID")
    private java.lang.String orderId;
    @ApiModelProperty(value = "试卷ID")
    private java.lang.String examId;
    @ApiModelProperty(value = "用户ID")
    private java.lang.String userId;
    @ApiModelProperty(value = "订单金额")
    private BigDecimal orderMonry;
    @ApiModelProperty(value = "支付金额")
    private BigDecimal payMonry;
    @ApiModelProperty(value = "订单状态")
    private java.lang.String orderStatus;
    @ApiModelProperty(value = "完成时间")
    private java.util.Date okTime;
    @ApiModelProperty(value = "备注")
    private java.lang.String remark;
    @ApiModelProperty(value = "支付方式")
    private java.lang.String payMethod;
    @ApiModelProperty(value = "创建时间")
    @JSONField(format = "yyyy.MM.dd HH:mm:ss")
    private java.util.Date createdTime;
    @ApiModelProperty(value = "修改时间")
    private java.util.Date modifiedTime;
    @ApiModelProperty(value = "有效标志（冻结/恢复）")
    private java.lang.String validFlag;
    @ApiModelProperty(value = "用户昵称")
    private java.lang.String userName;

    @ApiModelProperty(value = "订单细项")
    private String details;
    @ApiModelProperty(value = "试卷名称")
    private java.lang.String examName;
    @ApiModelProperty(value = "试卷价格")
    private BigDecimal examPrice;
    @ApiModelProperty(value = "试卷封面")
    private java.lang.String examCover;
    @ApiModelProperty(value = "试卷描述")
    private java.lang.String examDesc;

    @ApiModelProperty(value = "学期ID")
    private String termId;
    @ApiModelProperty(value = "学期名称")
    private String termName;
    @ApiModelProperty(value = "学期价格")
    private Long termPrice;
    @ApiModelProperty(value = "学期封面")
    private String termCover;
    @ApiModelProperty(value = "学期描述")
    private String termDesc;
    @ApiModelProperty(value = "所属年级")
    private String subGrade;
    @ApiModelProperty(value = "难度级别")
    private String difficultyLevel;
    @ApiModelProperty(value = "上架状态")
    private String onState;

    public String preUpdate(String orderId, BigDecimal payFee, String transactionId) {
        setPayMonry(payFee);
        setOrderId(orderId);
        setModifiedTime(new Date());
        setOkTime(new Date());
        setOrderStatus(TkConstants.ORDER_STATUS_PADED);
        setValidFlag("1");
        return orderId;
    }
}
